package movement;

import jgame.JGObject;

public class RandomEnemyMovement implements MoveModel {

	private double randomFactor;
	
	public RandomEnemyMovement(double randomFactor){
		this.randomFactor = randomFactor;
	}
	
	
	@Override
	public void move(JGObject obj){ {
		obj.xspeed = obj.xspeed + obj.eng.random(-randomFactor, randomFactor);
		obj.yspeed = obj.yspeed + obj.eng.random(-randomFactor, randomFactor);
		
		String curAnim;
		
		if (Math.abs(obj.xspeed) > Math.abs(obj.yspeed)){
			curAnim = obj.xspeed > 0 ? "enemy_r" : "enemy_l"; 
		} else {
			curAnim = obj.yspeed > 0 ? "enemy_u" : "enemy_d";
		}
		
		obj.setAnim(curAnim);

	}
	
	
	}	
}
